import axios from 'axios';

// 配置
const Util={
    imgPath:'http://192.168.13.158:8011/img/',
    apiPath:'http://192.168.13.158:8010'
};
// ajax通用配置
Util.ajax=axios.create({
    baseURL:Util.apiPath
});
// 拦截响应器
Util.ajax.interceptors.response.use(res=>{
    return res.data;
});

// 获取今日时间
Util.getTodayTime=function(){
    const date=new Date();
    date.setHours(0);
    date.setMinutes(0);
    date.setSeconds(0);
    date.setMilliseconds(0);
    return date.getTime();
};
//获取前一天时间
Util.prevDay=function(timestamp=(new Date()).getTime()){
    const date=new Date(timestamp);
    const year=date.getFullYear();
    const month=date.getMonth()+1<10
                ?'0'+(date.getMonth()+1)
                :date.getMonth()+1;
    const day=date.getDate()<10
            ?'0'+date.getDate()
            :date.getDate();
    return year+month+day;
};
export default Util;